package com.wushijia.designpatterns.single;

/**
 * @author 92090
 */
public class EnumSingleTest2 {
  private EnumSingleTest2() {
  }

  //使用枚举充当holder
  private enum EnumHolder {
    //持有单例对象
    INSTANCE;
    private EnumSingleTest2 instance;

    EnumHolder() {
      this.instance = new EnumSingleTest2();
    }

    public EnumSingleTest2 getInstance() {
      return instance;
    }
  }

  public static EnumSingleTest2 getInstance() {
    return EnumHolder.INSTANCE.getInstance();
  }
}
